package com.jf.furn.util;

import lombok.Data;
import lombok.Setter;

import java.util.HashMap;
import java.util.Map;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-12-17
 * Time:10:40
 */
@Data
public class Msg {
    private Integer code;
    private String msg;
    private Map<String, Object> extend = new HashMap<String, Object>();

    public static Msg success() {
        return success(200, "success");
    }

    public static Msg success(String message) {
        return success(200, message);
    }

    public static Msg success(Integer code, String message) {
        Msg msg = new Msg();
        msg.code = code;
        msg.msg = message;
        return msg;
    }

    public static Msg fail() {
        return fail(500, "fail");
    }

    public static Msg fail(String message) {
        return fail(500, message);
    }

    public static Msg fail(Integer code, String message) {
        Msg msg = new Msg();
        msg.code = code;
        msg.msg = message;
        return msg;
    }

    public void add(String key, Object value) {
        this.extend.put(key, value);
    }
}
